#!/bin/bash

cp ifcfg-ath0 /etc/sysconfig/network-scripts/
#cp ifcfg-wlan0 /etc/sysconfig/network-scripts/

dhclient ath0
#dhclient wlan0

var1=`ifconfig ath0 |awk '/inet/{print $2}'|awk -F: '{print $2}'`
#var1=`ifconfig wlan0 |awk '/inet/{print $2}'|awk -F: '{print $2}'`

var2=`ps aux|awk '/dhclient ath0/'|awk '$11!="awk"{print $2}'`
#var2=`ps aux|awk '/dhclient wlan0/'|awk '$11!="awk"{print $2}'`

kill $var2

rm -f /etc/sysconfig/network-scripts/ifcfg-ath0
#rm -f /etc/sysconfig/network-scripts/ifcfg-wlan0

echo "get ip: $var1"

